package marchsoft.modules.four.admin.service.Impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import marchsoft.base.BasicServiceImpl;
import marchsoft.base.PageVO;
import marchsoft.modules.four.common.entity.Slideshow;
import marchsoft.modules.four.common.mapper.MapperSlideshow;
import marchsoft.modules.four.admin.service.SlideshowService;
import marchsoft.utils.SecurityUtils;
import org.springframework.stereotype.Service;

import java.util.List;


@Slf4j
@Service
@RequiredArgsConstructor
public class SlideshowServiceImpl extends BasicServiceImpl<MapperSlideshow, Slideshow> implements SlideshowService {


    /*
    * 添加数据
    * */
    @Override
    public void saveSlide(Slideshow slideshow) {
        save(slideshow);
        log.info("【创建轮播图成功】操作人id：{}，创建目标job：{}", SecurityUtils.getCurrentUserId(),
                slideshow);
    }
    /*
    * 分页查询
    * */
    @Override
    public IPage<Slideshow> queryAll1(PageVO pageVO) {
        System.out.println(pageVO.getOrders());
        IPage<Slideshow> page = new Page<>(pageVO.getCurrent(), pageVO.getSize());
        QueryWrapper<Slideshow> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("create_time");
        return page(page, queryWrapper);
    }

    /*
    * 更新数据
    * */
    @Override
    public void update(Slideshow slideshow) {
        updateById(slideshow);
        log.info("【更新轮播图成功】操作人id：{}，创建目标job：{}", SecurityUtils.getCurrentUserId(),
                slideshow);
    }
    /*
    * 删除数据
    * */
    @Override
    public void delete(List<Integer> ids) {
        removeByIds(ids);
    }


}
